<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
   <%@ include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>${gallery.name }画廊基本信息及作品集</title>
<link href="../style/css_member.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/common.js"></script>
<script src="../js/artDialog.js?skin=gray"></script>
<script src="../js/artDialog.iframeTools.js"></script>
<script type="text/javascript" src="../js/jquery-1.3.2.js"></script>
<script type="text/javascript">

/******改变作品上传状态 *****/
function changeState(id,status){
	if(status == '2'){
		if (window.confirm("确认删除此作品？")) {
			$.ajax( {
				type : "POST",
				url : "${ctx}/painting/changeUploadState.do?painting.id="+id+"&operateStr="+status,
				timeout : 6000,
				async : false, //ajax同步
				success : function(data, textStatus) {
					if(data == '0000'){
						window.location.reload(true);
					}
				}
			});
		}
	}else{
		$.ajax( {
			type : "POST",
			url : "${ctx}/painting/changeUploadState.do?painting.id="+id+"&operateStr="+status,
			timeout : 6000,
			async : false, //ajax同步
			success : function(data, textStatus) {
				if(data == '0000'){
					window.location.reload(true);
				}
			}
		});
	}
}


$(function(){
    
	$("#galleryLink").click(function(){
		art.dialog.open('${ctx}/fileUpload!uploadPrepare.do?imgType=gallery&sharpId=9',{title:'修改画廊logo图片',width:800,height:550},false);
    });

    $("#addPaintingImage").click(function(){
    	art.dialog.open('${ctx }/painting/addPrepareByGallery.do?gallery_Id=${gallery.id }',{title:'为画廊添加作品',width:820,height:550,lock:true},false);
    });

    $("a[name='modifyHref']").click(function(){
		var id = $(this).attr("title");
		art.dialog.open('${ctx}/painting/modifyPrepare.do?painting.id='+id,{title:'修改作品',width:820,height:550,lock:true},false);
    });

    m2('m1_005','m1_005_04');

    var city_id = '${gallery.cityInfo.id}';
    checkCity(city_id);
});

	function checkForm(){
	
		var name = $.trim($("#name").val());
		if( name  ==  ""){
			$("#name").focus();
			 alert("画廊名称不能为空。");
			 return false;
		}
	
		var description =  $.trim($("#description").val());
		if( description  ==  ""){
			$("#description").val("");
			$("#description").focus();
			alert("画廊简介不能为空。");
			return false;
		}

		var province = $("#provinceInfoSelect").val();
		if( province == ""){
			 alert("请选择所在省。");
			 return false;
		}

		var city = $("#cityInfoSelect").val();
		if( city == ""){
			 alert("请选择所在市。");
			 return false;
		}
		
		if(window.confirm("确认修改？")){
			$.ajax({
				type:'POST',
				url:'${ctx }/gallery/galleryAction!modify.do',
				async : false, //ajax同步
				data:$("#galleryForm").serialize(),//序列化表单里所有的内容
				success: function(data){
				  if(data =='0000'){
		    			alert("画廊基本信息保存成功！");
		    			var win = art.dialog.open.origin;//来源页面
						// 如果父页面重载或者关闭其子对话框全部会关闭
						win.location.reload();
						return false;
					}else{
						alert("画廊基本信息保存失败！");
						return false;
					}
				}
			});
		}
	}
	
</script>	
	
</head>
<body>

<!-- 页面头部  -->
<jsp:include page="/commons/head_member.jsp"></jsp:include>

<form action="${ctx }/gallery/galleryAction!modify.do" method="post" id="galleryForm" name="galleryForm">
<table align="center" width="960" border="0" cellspacing="0" cellpadding="0"  class="tbl_border_top"  bgcolor="#ffffff">
          <tr>
            <td colspan="100%"><div align="center" class="bt14A">${gallery.name }画廊资料</div></td>
          </tr>
          <tr>
            <td class="bt14A" align="right"><span class="style15">*</span> 画廊名称：</td>
            <td class="bt14A"><input name="gallery.name" type="text" size="40" id="name" value="${gallery.name }"></td>
          </tr>
          <tr>
            <td class="bt14A" align="right"><span class="style15">*</span> 上传画廊logo：</td>
            <td class="bt14A"><span class="style18"><a id="galleryLink" style="cursor: pointer;color: red">上传</a></span></td>
          </tr>
          <tr>
            <td class="bt14A" align="right"><span class="style15">*</span> 画廊简介：</td>
            <td class="bt14A">
              <textarea name="gallery.description" cols="80" rows="8" id="description">${gallery.description }</textarea>
            </td>
          </tr>
          <tr>
            <td class="bt14A" align="right"><span class="style15">*</span> 所在地：</td>
            <td class="bt14A">
                <select name="gallery.provinceInfo.id" id="provinceInfoSelect" onchange="changeProvince()">
                        <option value="">选择省份</option>
                        <c:forEach items="${provinceInfoList}" var="provinceInfo" varStatus="status">
				            <option value="${ provinceInfo.id}" <c:if test="${gallery.provinceInfo.id == provinceInfo.id }">selected="selected"</c:if>/> ${ provinceInfo.name}</option>
				        </c:forEach>
                    </select>
                    <select name="gallery.cityInfo.id" id="cityInfoSelect">
                      <option value="">选择县市</option>
                    </select>
                <input name="gallery.address" type="text" size="40" id="address" value="${gallery.address }">
               </td>
          </tr>
          <tr>
            <td class="bt14A" align="right">业务联系人：</td>
            <td class="bt14A"><input name="gallery.contact" type="text" size="20" id="contact"  value="${gallery.contact }"></td>
          </tr>
          <tr>
            <td class="bt14A"  align="right">咨询电话：</td>
            <td class="bt14A"><input name="gallery.tel" type="text" size="20" id="tel"  value="${gallery.tel }">
            	<!-- 隐藏域 begin -->
            		<input name="gallery.id" type="hidden" size="20" id="gallery_id" value="${gallery.id }">
		            <input name="gallery.imageInfo.id" type="hidden"  id="picImage"  value="${gallery.imageInfo.id }">
		        <!-- 隐藏域 end --> 
            </td>
          </tr>
          <tr>
            <td width="180"></td>
            <td class="nw12a" align="left">
           		 <img src="../images/an24b.gif" width="106" height="31" onClick="javascript:checkForm()" style="cursor: pointer ;border: 0"></td>
          </tr>
</table>
   
<table align="center" width="960" border="0" cellspacing="0" cellpadding="0"  class="tbl_border"  bgcolor="#ffffff">
                <tr>
                  <td style="padding: 5px 0px 5px 35px;"><img src="../images/an12.gif" width="106" height="31" id="addPaintingImage" style="cursor: pointer;"></td>
                </tr>
               <tr><td colspan="100%" align="left">
						<table cellpadding="0" cellspacing="0" border="0">
							 <c:forEach items="${page.result}" var="result" varStatus="status">
					              <%@ include file="/member/painting_detail_fragment.jsp" %>
							</c:forEach>
						</table>
				</td></tr>
</table>
         
 </form>  

<jsp:include page="/commons/foot_member.jsp"></jsp:include>

</body>
</html>